<template>
	<view class="z-modal">
		<uni-popup ref="zModal" type="center">
			<view class="z-modal-box">
				<image class="close" @tap="hide" src="../../static/images/center/close.png" mode=""></image>
				<view class="content">{{content}}</view>
				<view class="btnBox">
					<view class="cancelBtn btn" v-if="cancelShow" :style="{color:cancelColor,backgroundColor:cancelBg,borderColor:cancelColor}" @tap="cancel">{{cancelText}}</view>
					<view class="confirmBtn btn" :style="{color:confirmColor,backgroundColor:confirmBg}" @tap="confirm">{{confirmText}}</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	export default {
		name: "zModal",
		components:{
			uniPopup
		},
		props: {
			// 提示内容
			content: {
				type: String,
				default: ''
			},
			// 确认按钮文字
			confirmText: {
				type: String,
				default: '确认'
			},
			// 确认按钮背景
			confirmBg: {
				type: String,
				default: '#FBC866'
			},
			//确认按钮文字颜色
			confirmColor: {
				type: String,
				default: '#fff'
			},
			//取消按钮文字
			cancelText: {
				type: String,
				default: '取消'
			},
			//取消按钮背景
			cancelBg: {
				type: String,
				default: '#fff'
			},
			//取消按钮文字颜色及描边颜色
			cancelColor: {
				type: String,
				default: '#FBC866'
			},
			//取消按钮是否显示
			cancelShow: {
				type: Boolean,
				default: true
			},
		},

		data() {
			return {
				
			}
		},
		methods:{
			//打开提示面板
			show() {
				this.$refs.zModal.open()
			},
			//关闭提示面板
			hide() {
				this.$refs.zModal.close()
			},
			// 点击确定按钮
			confirm() {
				this.$emit("confirm")
				this.hide()
			},
			// 点击取消按钮
			cancel() {
				this.$emit("cancel")
				this.hide()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.z-modal{
		.z-modal-box{
			width:540rpx;
			padding: 50rpx 30rpx;
			background:rgba(255,255,255,1);
			border-radius:10px;
			text-align: center;
			position: relative;
			.close{
				position: absolute;
				top:30rpx;
				right:30rpx;
				width: 30rpx;
				height: 30rpx;
				padding: 10rpx;
			}
			.content{
				text-align: justify;
				padding: 60rpx 20rpx 80rpx;
				font-size:36rpx;
				color:rgba(52,52,52,1);
			}
			.btnBox{
				display: flex;
				justify-content: space-around;
				.btn{
					width:200rpx;
					height:80rpx;
					line-height: 80rpx;
					font-weight: 500;
					box-sizing: border-box;
					border-radius:40rpx;
				}
				.cancelBtn{
					border-style: solid;
					border-width: 1rpx;
				}
			}
		}
	}
</style>
